<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="MobileOptimized" content="320" />
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <link rel="stylesheet" href="./css/jiazai.css">
    <link rel="stylesheet" type="text/css" href="css/animate.css"/>
    <link rel="stylesheet" type="text/css" href="css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    <title>主页</title>
    <style type="text/css">
		.animated {
		    animation-duration: .6s;
		    animation-fill-mode: both;
		}
    </style>
</head>

<body>
    <div id='app'>

         <!-- 加载中动画 -->
        <div id='jiazai-ani' v-if='jiazai'>
            <div class="arc"></div>
            <h1><span>LOADING</span></h1>
        </div>
        <!-- 加载中动画 -->
        
        <!--左边菜单 -->
        <div id="mask" v-if='leftContr' @tap="closeMask"></div>
        <transition enter-active-class='animated bounceInLeft' leave-active-class='animated bounceOutLeft'>
	        <div id="left-menu" v-if='leftContr'>
	        	<div class="user-info-top" style="padding: 0 20px;">
	        		<img src="img/index-user.png" style="width: 100%;height: auto;"/>
	        		<div class="dis-spa jihou-notice" v-if='showEx'>
	        			<p>免费</p>
	        			<p>体验</p>
	        		</div>
	        		<div class="user-intro dis-cen">
	        			<div class="user-no-login" v-if='!user' @tap="goLogin">
	        				去登录
	        			</div>
	        			<div class="user-yes-login" v-else>
	        				<p>用户:</p>
	        				<p v-text='user.phone'>------</p>
	        			</div>
	        		</div>
	        		<!--<div class="jihuo-hava-date">
	        			<p>体验</p>
	        			<p>还剩：<span>10</span>天</p>
	        		</div>-->
	        	</div>
	        	<div class="app-menu">
	        		<div class="dis-start app-menu-info" @tap="_openHref({url:'about-ai.html',id:'aboutAi'});leftContr=false;">
	        			<img src="img/about-me.svg"/>
	        			<span>关于AI矿池</span>
	        		</div>
	        		<div class="dis-start app-menu-info" @tap="_openHref({url:'share.html',id:'share'});leftContr=false;">
	        			<img src="img/share.svg" style="width: 33px;height: 33px;"/>
	        			<span>分享AI矿池</span>
	        		</div>
	        		<div class="dis-start app-menu-info" @tap="actiApp">
	        			<img src="img/jihuo.svg" style="width: 38px;height: 38px;"/>
	        			<span style="margin-left: 17px;">激活软件程序</span>
	        		</div>
	        		<div class="dis-start app-menu-info" style="border-bottom: 1px solid rgba(181, 209, 226,.5);" @tap="_openHref({url:'edition-update.html',id:'editionUpdate'});leftContr=false;">
	        			<img src="img/updown.svg" style="width: 33px;height: 33px;"/>
	        			<span>软件版本更新</span>
	        		</div>
	        		<div class="close-app" v-if='user' @tap='closeApp'>
	        			退出登录
	        		</div>
	        	</div>
	        </div>
        </transition>
        <!--左边菜单-->
        
        <div id="com-tit" class='dis-spa'>
        	<div class='cont' >
        		<p class='menu dis-start' @tap="leftContr=true;">
	        		<img src="img/menu.svg"/ style="width: 22px;height: 22px;">
        		</p>
        	</div>
        	<div>AI矿池</div>
        	<!--<div class='cont' :style="{'opacity':showEx?1:0}">体验还剩<span v-text='indexData.day'>--</span>天</div>-->
        	<div class='cont' style="opacity: 0;">体验还剩<span>0</span>天</div>
        </div>
        <div id="content-wrap">
        	<div class="index-img">
        		<img src="img/index-ban.jpg" style="width: 100%;height: auto;"/>
        		<div class="img-font dis-cen ">
        			<h4>AI矿池正式上线</h4>
        			<p>
        				<span>轻松赚钱</span>
        				<span>一键挖矿</span>
        			</p>
        		</div>
        	</div>
        	<div style="padding: 0 20px;">
        		<div class="notice" style="overflow: hidden;">
	        		<div class='dis-spa' style="overflow: hidden;">
	        			<p class='dis-start'>
	        				<img src="img/notice.svg" style="width: 20px;height: auto;margin-right: 6px;"/>
	        				<span class='no-content' v-text="indexData.article?indexData.article.title:'暂无公告'">---</span>
	        			</p>
	        			<span class='no-more' @tap="_openHref({url:'nitice-list.html',id:'niticeList',bg:'#efeff4'})">更多</span>
	        		</div>
	        	</div>
	        	<div class="" style="margin-top: 13px;">
	        		<img src="img/guangao.png" style="width: 100%;height: auto;"/>
	        	</div>
	        	<!--<div class="dis-start search-coins">
	        		<img src="img/search.svg" style="width: 25px;height: 25px;"/>
	        		<input type="text" placeholder="搜索币种"/>
	        	</div>-->
	        	<div class='coins-wrap'>
	        		<div class="coins-info">
	        			<div class="dis-start">
	        				<img src="img/coins.jpg" style="width: 40px;height: 40px;border-radius: 50%;"/>
	        				<span>BTC</span>
	        			</div>
	        			<p>BTC矿池总算力</p>
	        			<h3>1446.14172840<span>Ph/s</span></h3>
	        		</div>
	        		<div class="coins-info">
	        			<div class="dis-start">
	        				<img src="img/bch.jpg" style="width: 40px;height: 40px;border-radius: 50%;"/>
	        				<span>BCH</span>
	        			</div>
	        			<p>BCH矿池总算力</p>
	        			<h3>197.08948238<span>Ph/s</span></h3>
	        		</div>
	        		<div class="coins-info">
	        			<div class="dis-start">
	        				<img src="img/bt.jpg" style="width: 40px;height: 40px;border-radius: 50%;"/>
	        				<span>BT</span>
	        			</div>
	        			<!--<p>{{totalMiningBT}}<span style="color: #1994E8;">BT</span>/日 HPT收益</p>-->
	        			<p>AI机器人  BT/日收益(1%-20%)</p>
	        			<h3 v-text='totalMining'>1441.14521</h3>
	        			<p class='go-btn' @tap="goWa()">去挖矿</p>
	        		</div>
	        	</div>
	        	<div class="dis-spa bottom-line" style="opacity: 0;">
	        		<span></span>
	        		<span>我是底线</span>
	        		<span></span>
	        	</div>
        	</div>
        </div>
    </div>
    <script src="js/comm.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/vue.min.js"></script>
    <script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/update.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    	//登录成功后执行
    	var login=function(){
    		var all=plus.webview.all();
    		var curr=plus.webview.currentWebview();
    		for(var i=0;i<all.length;i++){
    			if(all[i].id!=curr.id){
    				all[i].hide();
    			}
    		}
    		setTimeout(function(){
    			for(var i=0;i<all.length;i++){
	    			if(all[i].id!=curr.id){
	    				all[i].close('none');
	    			}
	    		}
    		},1500);
    		//得到首页数据
    		app.getIndex();
    		//刷新user
    		app.$data.user=JSON.parse(localStorage.getItem('ai_user'));
    	};
        var app = new Vue({
            el: '#app',
            data: {
                //加载动画
                jiazai: false,
                //左边控制
                leftContr:false,
                //首页数据
                indexData:{},
                //用户数据
                user:localStorage.getItem('ai_user')?JSON.parse(localStorage.getItem('ai_user')):false,
                //下面的挖矿数据
                totalMining:0,
                //上面的挖矿数据
                totalMiningBT:0
            },
            created: function() {
				//得首页数据
				this.getIndex();
				//自动登录一次
				this.sessionLogin();
            },
            computed:{
            	showEx:function(){
            		if((!this.user)||(this.user&&String(this.user.avtivation)=='1')){
            			//灭有user或者激活就不显示
            			return false;
            		}
            		return true;
            	}
            },
            methods: {
            	//得到首页数据
            	getIndex:function(){
            		var This=this;
            		This.jiazai=true;
            		HTTP.post(INDEXDATA,{},function(data){
            			This.jiazai=false;
            			This.indexData=data;
            			This.totalMining=parseFloat(data.totalMining).toFixed(6);
            			This.totalMiningBT=parseFloat(data.totalMiningBT).toFixed(6);
					});
            	},
            	//自动登录
            	sessionLogin:function(){
            		var user=localStorage.getItem('ai_user');
            		if(user){
            			var json=JSON.parse(user);
            			var This=this;
	            		HTTP.post(SESSIONLOGIN,{
	            			account:json.phone,
	            			password:json.password,
	            			sessionId:json.session
	            		},function(data){
	            			if(String(data.status)=='1'){
	            				json.invitation=data.invitation;
	            				json.avtivation=data.avtivation;
	            				json.isbindApi=data.isbindApi;
	            				json.session=data.token;
	            				localStorage.setItem('ai_user',JSON.stringify(json));
	            			}else{
	            				localStorage.setItem('ai_user','');
	            				_toast(data.msg);
	            				setTimeout(function(){
	            					This.goLogin();
	            				},1500);
	            			}
						});
            		}
            	},
            	//关闭各种遮罩和模态框
            	closeMask:function(){
            		this.leftContr=false;
            	},
            	//去挖矿
            	goWa:function(){
            		if(!localStorage.getItem('ai_user')){
            			_toast('请登录后再试');
            			return;
            		}
            		_openHref({
            			url:'wakuang.html',
            			id:'wakuang'
            		});
            	},
            	//去登录
            	goLogin:function(){
            		var op = {
				        'backButtonAutoControl': 'close', //返回是关闭当前页
				        'animationOptimization': 'none', //不优化
				    };
				    this.jiazai = true;
				    var This=this;
				    var web = plus.webview.create('login.html', 'login', op);
				    web.addEventListener("loaded", function() {
				        setTimeout(function() {
				            This.jiazai = false;
				            This.leftContr=false;
				            web.show('slide-in-right');
				        }, 200);
				    }, false);
            	},
            	//去激活app
            	actiApp:function(){
            		if(!localStorage.getItem('ai_user')){
            			_toast('请登录后再试');
            			return;
            		}
            		_openHref({url:'activation.html',id:'activation'});
            		this.leftContr=false;
            	},
            	//退出登录
            	closeApp:function(){
            		var This=this;
            		plus.nativeUI.confirm('确定要退出登录吗?',function(ev) {
                       if (ev.index == 0) {
                       		This.jiazai=true;
		            		HTTP.post(CLOSELOGIN,{},function(data){
		            			This.jiazai=false;
		            			_toast('退出成功');
		            			localStorage.setItem('ai_user','');
		            			This.leftContr=false;
		            			setTimeout(function(){
		            				This.goLogin();
		            			},1000);
							});
                       }
                  	});
            	}
            }
        });
        mui.plusReady(function(){
        	_update();
        });
    </script>
</body>

</html>